package com.zc.domain;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

//import com.zc.service.DataService;
import com.zc.service.FaultService;
import com.zc.service.PowerFactorService;
import com.zc.service.PowerService;
import com.zc.service.PresService;
import com.zc.service.TcService;
import com.zc.service.TemService;
import com.zc.service.ElecService;
import com.zc.service.RedisService;
import com.zc.service.VibService;

@Component
public class TimedTaskThread implements Runnable{
//	@Autowired
//	private DataService dataService;
	@Autowired
	private FaultService faultService;
	@Autowired
	private PowerFactorService powerFactorService;
	@Autowired
	private PowerService powerService;
	@Autowired
	private PresService presService;
	@Autowired
	private TcService tcService;
	@Autowired
	private TemService temService;
	@Autowired
	private ElecService elecService;
	@Autowired
	private VibService vibService;
	@Autowired
	private RedisService redisService;
	@Override
	public void run() {
		// TODO Auto-generated method stub
		while(true) {
			DoubleListData elecData=elecService.getElec();
//			DoubleListData tickCountData=dataService.getTickCount();
//			List<Item> subPowerData=dataService.getSubPower();
//			List<Item> mainPowerData=dataService.getMainPower();
//			List<Item> subPowerFactorData=dataService.getSubPowerFactor();
//			List<Item> mainPowerFactorData=dataService.getMainPowerFactor();
//			List<Item> subPressureData=dataService.getSubPressure();
//			List<Item> mainPressureData=dataService.getMainPressure();
//			List<FourPointsItem> subTemperatureData=dataService.getSubTemperature();
//			List<FourPointsItem> mainTemperatureData=dataService.getMainTemperature();
//			List<TwoPointsItem> pressureData=dataService.getPressure();
//			List<FaultItem> curFaultData=dataService.getCurFault();
			DoubleListData tickCountData=tcService.getTickCount();
			List<Item> subPowerData=powerService.getSubPower();
			List<Item> mainPowerData=powerService.getMainPower();
			List<Item> subPowerFactorData=powerFactorService.getSubPowerFactor();
			List<Item> mainPowerFactorData=powerFactorService.getMainPowerFactor();
			List<Item> subPressureData=presService.getSubPressure();
			List<Item> mainPressureData=presService.getMainPressure();
			List<FourPointsItem> subTemperatureData=temService.getSubTemperature();
			List<FourPointsItem> mainTemperatureData=temService.getMainTemperature();
			List<TwoPointsItem> pressureData=presService.getPressure();
			List<FaultItem> curFaultData=faultService.getCurFault();
			FourPointsItem subVibrationData=vibService.getSubVibration();
			FourPointsItem mainVibrationData=vibService.getMainVibration();		
			
			redisService.set("elecData", elecData);
			redisService.set("tickCountData", tickCountData);
			redisService.set("subPowerData", subPowerData);
			redisService.set("mainPowerData", mainPowerData);
			redisService.set("subPowerFactorData", subPowerFactorData);
			redisService.set("mainPowerFactorData", mainPowerFactorData);
			redisService.set("subPressureData", subPressureData);
			redisService.set("mainPressureData", mainPressureData);
			redisService.set("subTemperatureData", subTemperatureData);
			redisService.set("mainTemperatureData", mainTemperatureData);
			redisService.set("subVibrationData", subVibrationData);
			redisService.set("mainVibrationData", mainVibrationData);
			redisService.set("pressureData", pressureData);
			redisService.set("curFaultData", curFaultData);
						
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
